package com.shcz.migu.observe.msg_observe;


import com.shcz.migu.observe.base_observe.IObserver;

/**
 * Created by Administrator on 2015/10/13.
 */
public class MsgObserverService {
    private static MsgObserverService mService;
    private MsgObserverNode mObserverNode;

    public static MsgObserverService getInstance(){
        if(null == mService){
            synchronized (MsgObserverService.class){
                if (null == mService){
                    mService = new MsgObserverService();
                }
            }
        }
        return  mService;
    }

    private MsgObserverService(){
        initService();
    }

    private void initService() {
        mObserverNode = new MsgObserverNode();
    }

    public void registerObserver(IObserver observer){
        mObserverNode.registerObserver(observer);
    }

    public void unRegisterObserver(IObserver observer){
        mObserverNode.unRegisterObserver(observer);
    }


    public void notifyDataChanged(int requestCode){
        mObserverNode.setRequestCode(requestCode);
        mObserverNode.notifyDataChanged();
    }
}
